/*
 * Copyright (c) 2023 Cshoo Org. All Rights Reserved.
 */

package org.cshoo.tattoo.authorize.domain.repository;

import org.cshoo.tattoo.authorize.domain.po.App;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;

/**
 * @author 杨翼
 * @since 1.0
 */
public interface IAppRepository extends CrudRepository<App, Long> {

    @Query("update App app set app.name = :#{#app.name}, app.uri = :#{#app.uri}, app.description = :#{#app.description}, app.lastUpdatedBy = :#{#app.lastUpdatedBy}, app.lastUpdateTime = :#{#app.lastUpdateTime} where app.id = :#{#app.id}")
    @Transactional
    @Modifying
    void updateApp(App app);

    App findAppByCode(String code);

}
